package com.igeek.boot.controller;

import com.igeek.boot.entity.Items;
import com.igeek.boot.service.ItemsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @package com.igeek.boot.controller
 * @Description
 * @Author LittlePunk [296526219@qq.ccom]
 * @Version 2022.1
 * @Date 2023/12/20 19:56
 */
@RestController
@RequestMapping("/items")
@Api(tags = "商品接口")
public class ItemsController {

    @Autowired
    private ItemsService itemsService;

    @ApiOperation("查询商品列表")
    @GetMapping("/findOne/{id}")
    public Items findOne(@PathVariable("id") Integer id){
        return itemsService.findOne(id);
    }

    @ApiOperation("更新商品明细")
    @PutMapping("update")
    public Items update(Items items){
        return itemsService.update(items);
    }

    @ApiOperation("删除商品")
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Integer id){
        itemsService.delete(id);
    }

    @GetMapping("findByName")
    public Items findByName(String name){
        Items items = itemsService.findByName(name);
        return items;
    }
}
